<div class="headertitle">
	<span class="header"><?php echo $this->Html->link("Forums", array("controller" => "forums", "action" => "displayForums")); ?></span>
	<span class="header"><?php echo $this->Html->link($threads[0]['SubForum']['name'], array(
		"controller" => "subForums",
		"action" => "displayTopics",
		"id" => $threads[0]['Thread']['sub_forum_id'],
		"slug" => Inflector::slug($threads[0]['SubForum']['name'], '-')
		));
		?></span>
	<span class="header"><?php echo Sanitize::html($threadTitle); ?></span>
</div>
<?php
	if($threads[0]['Thread']['locked']){
		echo $this->Html->image("forum_locked.png");
	}else{
		echo $this->Html->link(
			$this->Html->image("forum_postreply.png"), array(
				'controller' => 'threads',
				'action' => 'reply',
				'parentId' => $this->request->params['id'],
				'quoteId' => 0,
				'slug' => Inflector::slug($threads[0]['Thread']['title'], '-')
			),
			array('escape' => false)
		);
	}
?>

<div style="float: right; margin-bottom: 10px">
<?php
	$this->Paginator->options(array(
		'url' => array(
			'controller' => 'threads',
			'action' => 'view',
			'id' => $this->params['id'],
			'slug' => $this->params['slug']
		)
	));
	echo $this->Paginator->numbers();

?>
</div>
<?php echo (AuthComponent::User('role') >= 2) ? $this->Element('thread_subscribers') : ''; ?>
<?php
if($isSubscribed){
	echo $this->Element('subscribed_banner');
}
?>
<?php foreach($threads as $thread): ?>
<a id="<?php echo $thread['Thread']['id']; ?>"></a>

<div class="threadview" style="margin-top: 10px">
		<div class="threadTop">
			<div class="threadTopLeft">
				<div class="thread_author">
					<?php
					echo $this->Html->link($thread['User']['username'], array(
						'controller' => 'users',
						'action' => 'profile',
						'user' => $thread['User']['username']
					));
					?>
				</div>
			</div>
			<div class="threadTopRight">
				<div class="threadTopControls">
					<div style="float: right">
						<?php
							if($thread['Thread']['canEdit'] == "1"){
								echo $this->Html->link(
									$this->Html->image('icons/pencil.png'
										, array("class" => "threadEditIcon")), array(
										"controller" => "threads",
										"action" => "edit",
										"id" => $thread['Thread']['id'],
										"slug" => Inflector::slug($thread['Thread']['title'], '-')
									),
									array('escape' => false, "alt" => "Edit", "title" => "Edit")
								);
							}
						?>
						</div>
						<div style="float: right">
						<?php
							if(AuthComponent::User('role') == "3"){
								// sticky
								echo $this->Form->postLink(
									$this->Html->image('pinned.png'
										, array("class" => "threadEditIcon")), array(
										"controller" => "threads",
										"action" => "sticky",
										"id" => ($thread['Thread']['thread_id'] == "0") ? $thread['Thread']['id'] : $thread['Thread']['thread_id'],
										"slug" => Inflector::slug($thread['Thread']['title'], '-')
									),
									array('escape' => false, "alt" => "Sticky", "title" => "Sticky")
								);
						?>
						</div>
						<div style="float: right">
							<?php
							// add to homepage
							echo $this->Html->link(
								$this->Html->image('house.png', array("class" => "threadEditIcon")), array(
									"controller" => "threads",
									"action" => "setHome"	,
									"id" => $this->request->params['id']
								),
								array('escape' => false, "alt" => "Add to Homepage", "title" => "Add to Homepage")
							);
							?>
						</div>
						<div style="float: right">
						<?php
								// lock
								echo $this->Form->postLink(
									$this->Html->image('lock-icon.png', array("class" => "threadEditIcon")), array(
										"controller" => "threads",
										"action" => "lock",
										"id" => ($thread['Thread']['thread_id'] == "0") ? $thread['Thread']['id'] : $thread['Thread']['thread_id'],
										"slug" => Inflector::slug($thread['Thread']['title'], '-')
									),
									array('escape' => false, "title" => "Lock")
								);
							}
						?>
						</div>
						<div style="float: right">
							<?php
							// quote
							echo $this->Html->link(
								$this->Html->image('quotes.png', array("class" => "threadEditIcon")), array(
									"controller" => "threads",
									"action" => "reply"	,
									"id" => $this->request->params['id'],
									"quote_id" => $thread['Thread']['id'],
									"slug" => Inflector::slug($thread['Thread']['title'], '-')
								),
								array('escape' => false, "title" => "Quote")
							);
							?>
						</div>
				</div>
				<?php echo 'Posted on ' . date("d M Y, h:i:s", strtotime($thread['Thread']['created'])); ?>
			</div>
			<div style="clear: both"></div>
		</div>
		<div class="threadLeft">
			<div class="display_picturethread">
				<?php echo $this->Html->image('/attachments/avatars/large/' . $thread['User']['user_file_path']); ?>
			</div><br style="clear: both" />
			<div class="threadLeftDetails">
				Access: <?php echo $roles[$thread['User']['role']]; ?><br />
				Total Posts: <?php echo $thread['User']['thread_count']; ?><br />
				Joined: <?php echo substr($thread['User']['created'], 0, 10); ?><br /><br />
			</div>
		</div>
		<div class="threadRight">
			<?php
				echo Markdown($thread['Thread']['body']);
			?>
		</div>
	<div style="width: 895px">
		<div style="float: left; width: 153px"></div>
		<div style="float: right; width: 743px">
			<div style="float: right">
				<a href="#<?php echo $thread['Thread']['id']; ?>">#<?php echo $thread['Thread']['id']; ?></a>
			</div>
			<div class="threads_date thread_edit">
				<?php if(!empty($thread['Thread']['lasteditor'])): ?>
					Last edited by <?php echo $thread['EditUser']['username']; ?>
					at <?php echo $thread['Thread']['modified']; ?>
					Reason: <?php echo Sanitize::html($thread['Thread']['editreason']); ?>
				<?php endif; ?>
			</div>
		</div>
	</div>
	<div style="clear: both"></div>
</div>

<?php endforeach; ?>
<?php
	if($threads[0]['Thread']['locked']){
		echo $this->Html->image("forum_locked.png");
	}else{
		echo $this->Html->link(
			$this->Html->image("forum_postreply.png"), array(
				'controller' => 'threads',
				'action' => 'reply',
				'parentId' => $this->request->params['id'],
				'quoteId' => 0,
				'slug' => Inflector::slug($threads[0]['Thread']['title'], '-')
			),
			array('escape' => false)
		);
	}
?>
<div style="float: right; margin-bottom: 10px">
<?php
	$this->Paginator->options(array(
		'url' => array(
			'controller' => 'threads',
			'action' => 'view',
			'id' => $this->params['id'],
			'slug' => $this->params['slug']
		)
	));
	echo $this->Paginator->numbers();

?>
</div>